<VirtualHost *:{{ http_port }}>
        ServerName {{ servername }} 
        
        ServerAdmin webmaster@localhost
        DocumentRoot {{ docroot }} 

        <Directory {{ docroot }}>
                AllowOverride All
                Require all granted
        </Directory>

        DirectoryIndex /index.php index.php /index.html index.html

        {% if apache_logformat is defined %}
        # Custom LogFormat
        LogFormat "{{ apache_logformat }}" custom 
        {% endif %}

        ErrorLog ${APACHE_LOG_DIR}/{{ project_name }}-error.log
        CustomLog ${APACHE_LOG_DIR}/{{ project_name }}-access.log custom 

        {% if apache_custom is defined %}
        IncludeOptional {{ apache_custom }}
        {% endif %}
</VirtualHost>

{% if https_port is defined %}
<IfModule mod_ssl.c>
        <VirtualHost _default_:{{ https_port }}>
                ServerName {{ servername }}
                
                ServerAdmin webmaster@localhost
                DocumentRoot {{ docroot }} 

                <Directory {{ docroot }}>
                        AllowOverride All
                        Require all granted
                </Directory>

                DirectoryIndex /index.php index.php /index.html index.html

                {% if apache_logformat is defined %}
                # Custom LogFormat
                LogFormat "{{ apache_logformat }}" custom 
                {% endif %}

                ErrorLog ${APACHE_LOG_DIR}/{{ project_name }}-ssl_error.log
                CustomLog ${APACHE_LOG_DIR}/{{ project_name }}-ssl_access.log custom 

                SSLEngine on
                SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
                SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

                {% if apache_custom is defined %}
                IncludeOptional {{ apache_custom }}
                {% endif %}

                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        </VirtualHost>
</IfModule>
{% endif %}
